package com.itheima.dao;

import com.itheima.domain.Account;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

/**
 * Created by pc on 2021/1/28 23:06
 * Description: day04_eesy_04annoOne2Many
 */
public interface IAccountDao {
    /*查询所有账户,并且获取每个账户所属的用户信息*/
    @Select("select * from account")
    @Results(id = "accountMap", value = {
            @Result(id = true, column = "id", property = "id"),
            @Result(column = "uid", property = "uid"),
            @Result(column = "money", property = "money"),
            @Result(property = "user", column = "uid", one = @One(select = "com.itheima.dao.IUserDao.findById", fetchType = FetchType.EAGER))
    })
    List<Account> findAll();


    @Select("select * from account where uid=#{userId}")
   List<Account> findAccountByUid(Integer userId);

}
